var app=angular.module('myApp', []).
  config(['$routeProvider', function($routeProvider) {
  $routeProvider.
      when('/', {templateUrl: 'allcust.html', controller: ListExpMstCtrl}).      
      when('/cancel/', {templateUrl: 'allcust.html', controller: ListExpMstCtrl}). 
      otherwise({redirectTo: '/'});
}]);


function ListExpMstCtrl($scope, $http,$window,$location,$filter)
 {
		$scope.currentPage = 0;
		$scope.pageSize = 25;
		$scope.Math = window.Math;
		$scope.ed = false;
		$scope.n_arr = [];
		var j = 0;
		
		$http.get('allcustdata.php').success(function(data) {
			$scope.cmast = data;
			for(var i=0; i<data.length;i++)				
				if($scope.n_arr.indexOf(data[i].cname) == -1)
					$scope.n_arr[j++] = data[i].cname;
		});
	  
	  //Function to Clear 
        $scope.cancel= function()
		{
			$scope.activePath = null;
			$scope.activePath = $location.path('allcust.php');
		};
      
 }
    
        //Custom Filter Function to sort the record.
app.filter('startingFrom', function() 
{
    return function(input, start) 
    {
        start = +start; //parse to int
        return input.slice(start);
    };
});
	
app.filter('exact', function(){
  return function(items, match){
    var matching = [], matches, falsely = true;
	angular.forEach(match, function(value, key){
      falsely = falsely && !value;
    });
    if(falsely){
      return items;
    }
    angular.forEach(items, function(item){ // e.g. { title: "ball" }
      matches = true;
      angular.forEach(match, function(value, key){ // e.g. 'all', 'title'
        if(!!value) // do not compare if value is empty
          matches = matches && (item[key] === value);          
      });
      if(matches)
        matching.push(item);        
    });
    return matching;
  }
});
	
	
 
        